package com.android.supermarket.component

import android.graphics.Color
import android.view.Gravity
import com.android.supermarket.R
import com.android.supermarket.activity.UsbConnectionActivity
import com.android.supermarket.activity.WIFIConnectionActivity
import com.android.supermarket.activity.WelcomeActivity
import org.jetbrains.anko.AnkoComponent
import org.jetbrains.anko.AnkoContext
import org.jetbrains.anko.*
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * Created by pengtaoH on 2018/7/19.
 */
class WelcomeActivityUI : AnkoComponent<WelcomeActivity> {
    companion object {
        val img_id = 1
        val btn_next = 2
        val progress_normal = 3
    }

    override fun createView(ui: AnkoContext<WelcomeActivity>) = with(ui) {
        verticalLayout {
            id = img_id
            backgroundColor = Color.WHITE
            gravity = Gravity.RIGHT

            progressBar {
                id = progress_normal
                progress = 20
                max = 100

            }.lparams(width = matchParent, height = wrapContent) {
                margin = dip(20)
            }

            button("wifi") {
                onClick {
                    startActivity<WIFIConnectionActivity>()
                }
            }

            button("usb") {
                onClick {
                    startActivity<UsbConnectionActivity>()
                }
            }

        }

    }
}